﻿<local:TWPage
    x:Class="metroCIS.Win8Application.Views.LVPlanView"
    IsTabStop="false"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:metroCIS.Win8Application.Views"
    xmlns:vm="using:metroCIS.ViewModel"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <local:TWPage.DataContext>
        <vm:LVPlanViewModel />
    </local:TWPage.DataContext>
    <local:TWPage.Resources>
        <CollectionViewSource
            x:Name="groupedItemsViewSource"
            Source="{Binding Lessons}"
            IsSourceGrouped="true"
            ItemsPath="Value"/>
    </local:TWPage.Resources>
    
    <GridView ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}" 
                SelectionMode="None"
                IsItemClickEnabled="False">
        <GridView.ItemTemplate>
            <DataTemplate>
                <Border Margin="6" BorderBrush="{StaticResource twGreen}" BorderThickness="1">
                    <Grid Width="250" Height="250">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Image Opacity="0.8"  Stretch="UniformToFill"  Grid.Row="0" Source="http://www.technikum-wien.at/img/db/thumbs/2303_header_technikum_blau.jpg"/>
                        <Border Grid.Row="1" Background="{StaticResource twGreen}">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="*" />
                                </Grid.RowDefinitions>
                                <TextBlock Margin="3" Grid.Row="0" Text="{Binding Title}"/>
                                <TextBlock Margin="3" Grid.Row="1" Text="{Binding Lector}"/>
                                <TextBlock Margin="3" Grid.Row="2" Text="{Binding Room}"/>
                                <StackPanel Orientation="Horizontal" Grid.Row="3">
                                    <TextBlock Margin="3" Text="{Binding From,Converter={StaticResource StringConverter},ConverterParameter='t'}"/>
                                    <TextBlock Margin="3" Text=" - "/>
                                    <TextBlock Margin="3" Text="{Binding To,Converter={StaticResource StringConverter},ConverterParameter='t'}"/>
                                </StackPanel>
                            </Grid>
                        </Border>
                    </Grid>
                </Border>
            </DataTemplate>
        </GridView.ItemTemplate>
        
        <GridView.ItemsPanel>
            <ItemsPanelTemplate>
                <WrapGrid  />
            </ItemsPanelTemplate>
        </GridView.ItemsPanel>
        
        <GridView.GroupStyle>
            <GroupStyle HidesIfEmpty="True">
                <GroupStyle.HeaderTemplate>
                    <DataTemplate>
                        <Grid VerticalAlignment="Center" Margin="10" Width="250" Background="{StaticResource twBlue}">
                            <TextBlock VerticalAlignment="Center" Text="{Binding Key}" Foreground="White" Margin="10" FontSize="18" Style="{StaticResource HeaderTextStyle}"/>
                        </Grid>
                    </DataTemplate>
                </GroupStyle.HeaderTemplate>
            </GroupStyle>
        </GridView.GroupStyle>
    </GridView>
</local:TWPage>